package com.itheima.clientAndService01;

public class ArrayClass {
    public static void main(String[] args) {
        //有一个字符串：“91 27 46 38 50”
        // 请写程序实现最终输出结果是：27 38 46 50 91
        String str = "91 27 46 38 50";
        String[] s = str.split(" ");
        int[] arr = new int[s.length];
        for (int i = 0; i < s.length; i++) {
            arr[i] = Integer.parseInt(s[i]);
        }
        sortMethod(arr);
    }

    private static void sortMethod(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length -i - 1; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
